Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[windows] Fix idempotence when reinstalling same pinned version #269

Merged
merged 2 commits into from
Jul 6, 2020

Conversation

KSerrania
Copy link
Contributor

What does this PR do?

Fetches the currently installed Agent version to avoid downloading the msi installer whenever possible.
It won't work with rc and beta builds (Get-WmiObject doesn't return these), nor it will work with latest (since we currently have no way of knowing which version "latest" will install), but this should cover most common pinned installs use cases.

Motivation

Make role more idempotent.
Should partially fix this issue: #265.

# the package).
- name: Check currently installed Agent version
win_shell: |
$product_name = "Datadog Agent"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On Chef we use agent status for this: https://github.com/DataDog/chef-datadog/blob/483f88a43569b1efd00e7d5c0cb1e479eb09b1a2/libraries/recipe_helpers.rb#L92

I'm not sure which approach is better, but I think we shouldn't have two.

Copy link
Contributor Author

@KSerrania KSerrania Mar 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The Chef approach is slightly better because it would work with rc and beta builds.

However, contrary to this method, it does have a caveat: it only works if you know where the Agent binary is located at (Chef expects it to be C:/Program Files/Datadog/Datadog Agent/bin/agent).

One thing to note is that we currently don't offer the possibility to choose the application directory for Windows install; we do have a datadog_agent_binary_path_windows parameter, but it's not advertised in the README (and thus I suppose it's an internal parameter) and only used for the integration command, so we could use this option here to use agent status (that way people can still configure it for their use case if needed).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we have a variable for the Agent path, then I think using that to call the binary is reasonable (assuming we won't change the output of agent status).

I'm not sure this is necessarily better than your approach, though. I would still sync with @kbogtob, who wrote the Chef code I linked before, to discuss pros and cons of both approaches.

Copy link
Contributor

@albertvaka albertvaka left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No need to block this over the discussion on how to query the Agent version, approving.

@KSerrania KSerrania merged commit 0c6a1cb into master Jul 6, 2020
@KSerrania KSerrania deleted the kserrania/fix-idempotence-windows branch July 6, 2020 16:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants